<?php include PATH_VIEWS . 'common/header.php'; ?>
<div class="main">
    <?php include PATH_VIEWS . 'common/left.php'; ?>
    <div class="main_right welcome_right" id="slide">
        <dl>
            <dt><h3>操作说明 <span>[关闭/展开]</span></h3></dt>
            <dd class="border">
                <span>以下红色边框的表单是必填项 。</span>
            </dd>
        </dl>
        <dl>
            <dt class="bottom">
            <h4>添加产品菜单</h4>
            </dt>
            <dd>
                <form id="form1" name="form1" method="post" action="<?php echo URL; ?>">
                    <table class="system_envir from_demo"> 
                        <tr>
                            <td>上级菜单名称</td>
                            <td>
                                <select id="fist_menu" name="FcateIds[]" onchange="getMenu(this.value)">
                                    <option value="0">顶级</option>
                                    <?php foreach ($menu_list as $ls) { ?>
                                        <option value="<?php echo $ls['Fid']; ?>" <?php echo ($ls['Fid'] == $cate_id) ? "selected=selected" : ''; ?>><?php echo $ls['Fname']; ?></option>
                                    <?php } ?>
                                </select>
                                <select id="showMenu" name="FcateIds[]" >
                                    <?php
                                    if (isset($cate_two_menu)) {
                                        foreach ($cate_two_menu as $ls1) {
                                            ?>
                                            <option value="<?php echo $ls1['Fid']; ?>" <?php echo ($ls1['Fid'] == $two_id) ? "selected=selected" : ''; ?>><?php echo $ls1['Fname']; ?></option>
                                        <?php } ?>
                                    <?php } ?>
                                </select>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>菜单名称</td>
                            <td class="email"><input type="text" id="menuVal" name="Fname" value="<?php echo $edit['Fname']; ?>" maxlength="16" data-rule="required;length[2~32]" data-target="#tishi"/></td>
                            <td id="tishi">在填写菜单名称时，请注意简短且要具有概括性。字符长度：2-16个</td>
                        </tr>
                        <tr>
                            <td>产品总数量</td>
                            <td><input type="text" id="sort" name="FtotalProductNum" value="<?php echo $edit['FtotalProductNum']; ?>" maxlength="5"/></td>
                            <td class="tishi">产品的总数量</td>
                        </tr>
                        <tr>
                            <td>排序</td>
                            <td class="sort"><input type="text" id="sort" name="Fsort" value="<?php echo $edit['Fsort']; ?>" maxlength="2"/></td>
                            <td class="tishi">数值越小，排列越前，数值大小范围：1-99</td>
                        </tr>
                        <tr>
                            <td>是否可见</td>
                            <td>
                                <select name="Fstatus" class="show">
                                    <option value="1" <?php echo ($edit['Fstatus'] == 1) ? "selected=selected" : ''; ?>>是</option>                           
                                    <option value="0" <?php echo ($edit['Fstatus'] == 0) ? "selected=selected" : ''; ?>>否</option>
                                </select>
                            </td>
                            <td>是否可见的意思是，是否在页面顶部或左侧将此菜单显示出来</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="subbtn" colspan="2">
                                <input class="ok" type="submit" name="ok" value="确认提交">
                                <a href="index.php?C=Web&A=productMenu&way=S" class="cancel">返回</a>
                            </td>
                        </tr>
                    </table>
                </form>
            </dd>
        </dl>
        <div id="test"></div>
    </div>
</div>
<?php include PATH_VIEWS . 'common/footer.php'; ?>
<script>
    function getMenu(parent_id) {
        if (parent_id == 0) {
            $("#showMenu").addClass('hide');
        } else {
            $("#showMenu").removeClass('hide');
        }
//    取数据库菜单
        $.get('index.php?C=Web&A=menuGrade&pid=' + parent_id, function (data) {
            $('#showMenu').html(data);
        });
    }
    var level = <?php echo $edit['Flevel']; ?>;
    function showMenu() {
        if (level <= 2) {
            $("#showMenu").addClass('hide');
        } else {
            $("#showMenu").removeClass('hide');
        }
    }
    showMenu();
</script>